using System;
using Godot;
using MyCraft2;

public partial class TimeLabel : Label
{
    private World? _world;
    public override void _Ready()
    {
        base._Ready();

        _world = (World)GetNode<Node3D>("../../../World");
    }

    public override void _Process(double delta)
    {
        base._Process(delta);

        if (_world is not null)
        {
            var hours = (int)_world.DayTime; // 提取小时部分
            var decimalPart = (double)(_world.DayTime - hours); // 获取小数部分
        
            var minutes = (int)Math.Round(decimalPart * 60); // 转换为分钟
        
            Text = $"Time:{hours}:{minutes} Day:{_world.DayOfYear}";
        }
    }
}